package com.example.custcomsumer.controller;

import com.example.custcomsumer.entity.CustInfo;
import com.example.custcomsumer.entity.Label;
import com.example.custcomsumer.service.CustInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/info-consumer")
@RestController
@CrossOrigin
public class CustInfoConsumerController {

    @Autowired
    private CustInfoService custInfoService;

    @GetMapping("/selectCustomBySql/{currentPage}/{pageSize}")
    public List<CustInfo> selectFindBySql(@PathVariable("currentPage") int currentPage, @PathVariable("pageSize") int pageSize) {
        return custInfoService.selectFindBySql(currentPage, pageSize);
    }

    @GetMapping("/getTotal")
    public Integer getTotal() {
        return custInfoService.getTotal();
    }

    @GetMapping("/select/{currentPage}/{pageSize}")
    public List<Label> select(@PathVariable("currentPage") int currentPage, @PathVariable("pageSize") int pageSize) {
        return custInfoService.select(currentPage, pageSize);
    }

    @GetMapping("/selectGoal/{currentPage}/{pageSize}")
    public List<Label> selectGoal(@PathVariable("currentPage") int currentPage, @PathVariable("pageSize") int pageSize) {
        return custInfoService.selectGoal(currentPage, pageSize);
    }

    @GetMapping("/getSelect")
    public Integer getSelect() {
        return custInfoService.getSelect();
    }

    @GetMapping("/getSelectGoal")
    public Integer getSelectGoal() {
        return custInfoService.getSelectGoal();
    }

    @GetMapping("/setGoal/{id}")
    public void setGoal(@PathVariable("id") String id) {
        int realID  = Integer.parseInt(id);
        custInfoService.setGoal(realID);
    }

    @GetMapping("/cancelGoal/{id}")
    public void cancelGoal(@PathVariable("id") String id) {
        int realID  = Integer.parseInt(id);
        custInfoService.cancelGoal(realID);
    }
}
